< previous page page_118 next page >

Page 118
Save and run the program. You can see that when the control is initialized, the phone number mask is displayed. When the MaskedEdit control receives the focus, a series of underlines appear as an input guide for the user. The underlines disappear when control is given to an object other than the MaskedEdit control.
Note.gif
The formatting characters of the MaskedEdit control are not saved to the database field when the PromptInclude property is set to False. This means that in the previous example, only the phone number digits would be saved to the data table, not the parentheses or the dash.

The Visual Basic 5 MaskedEdit control offers an extensive set of input masking tools. It ships with several input masks predefined, including dollar amounts, U.S. phone numbers, and several date and time formats. To view these formats, select the MaskedEdit control, click the right (alternate) mouse button, and select Properties from the menu that appears. You find the formats on the General tab.
You can also create custom input format masks for inventory part numbers, e-mail addresses, and so on. Although we won't cover all the possibilities here, there is one other MaskedEdit format option that you illustrate on your form in this lesson because it is very useful when displaying dollar amounts.
The MaskedEdit control gives you the power to add a display mask in addition to an input mask. Up to this point, you have been using the input mask capabilities of the MaskedEdit control. Now let's add a control that shows the display capabilities, too.
Add another label control and another MaskedEdit control to the form. Set the label caption property to Dollars. Set the MaskedEdit control Name property to mskDollars and the format property to $#,##0.00;($#,##0.00).
Tip.gif
The MaskedEdit display property actually has three parts, each separated by the semicolon (;). Part one determines how positive values are displayed. Part two determines how negative values are displayed. Part three determines how zero values are displayed.

This property affects the display of the data, not the input, so you do not see any input guides when you set the format property or when you save and run the program. Your form should look like the one in Figure 5.5.

 
< previous page page_118 next page >

If you like this book, buy it!